Set objShell = WScript.CreateObject("WScript.Shell") 
Set fso = CreateObject("Scripting.FileSystemObject") 
strComputer = "." 
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") 
Set colItems = objWMIService.ExecQuery("Select * From Win32_Process") 
Dim isRunning 
isRunning = False 
For Each objItem in colItems 
  If InStr(objItem.CommandLine, "emacs.exe") Then 
    isRunning = True 
  End If 
Next 
parent = fso.GetParentFolderName(WScript.ScriptFullName) 
If WScript.Arguments.Count = 1 Then 
  If isRunning Then 
    callString = parent & "/emacsclientw.exe -n """ & 
WScript.Arguments(0) & """" 
  Else 
    callString = parent & "/runemacs.exe """ & WScript.Arguments(0) & """" 
  End If 
Else 
  If isRunning Then 
    callString = parent & "/emacsclientw.exe -n -e ""(raise-frame)""" 
  else 
    callString = parent & "/runemacs.exe" 
  End If 
End if 
objShell.Run(callString) 

